#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N=1e5+10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//
int a[N],n;
void solve()
{
	cin>>n;
	ll sum=0;
	for(int i=0;i<n;i++) cin>>a[i],sum+=a[i];

	bool ok=false;
	int num1=0,num11=0;
	for(int i=0;i<n;i++)
	{
		if(i<n-1&&a[i]==-1&&a[i+1]==-1) ok=true;
		if(a[i]==1) num1++;
		if(a[i]==-1) num11++;
	}
	//cout<<num1<<" "<<num11<<'\n';
	if(ok) sum+=4;
	else if(num1>0&&num11>0) sum+=0;
	else if(num1>0&&num11==0) sum-=4;

	cout<<sum<<'\n';




	
}

int main()
{
	close();
	int T; cin>>T;
	while (T--) solve();
	return 0;
}